<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt"  prefix="fmt"
%>
<!DOCTYPE HTML>
<html>
  <head>
     <title>
        	搜索结果
	</title>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/font-awesome.min.css"  />
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/bootstrap.min.css"  />
</head>
<script src="${pageContext.request.contextPath}/js/jquery-1.6.3.js"></script>
 <script src="${pageContext.request.contextPath}/js/bootstrap.min.js"></script>
  <script src="${pageContext.request.contextPath}/css/unslider.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
});
</script>
<body>
  	<c:if test="${user==null }">
	<div style="background: #F5F5F5;height:40px;" id="topdiv">
		<div style="margin-top:10px;margin-left:40px;">
			您好!请<a href="${pageContext.request.contextPath}/login.jsp" target="_blank">登录!</a>
		</div>
		<div style="margin-left:20px;">
			马上<a href="${pageContext.request.contextPath}/register.jsp" target="_blank">注册!</a>
		</div>
		<div style="margin-left:700px;">
			<a href="${pageContext.request.contextPath}">商城首页 <span class="fa fa-home" style="color:#FF7F00">
			</span>
			</a>
		</div>
		<div style="margin-left:50px;">
			<a id="carta" href="${pageContext.request.contextPath}/CartController/listCartByUser.action">购物车 <span class="fa fa-shopping-cart"
				style="color:#FF7F00"></span>
			</a>
		</div>
		<div style="margin-left:50px;">
			<a id="carta" href="${pageContext.request.contextPath}/user/center.action">个人中心 <span class="fa fa-user-circle-o"
				style="color:#FF7F00"></span>
			</a>
		</div>
	</div>
	</c:if>
	<c:if test="${user!=null }">
	<div style="background: #F5F5F5;height:40px;" id="topdiv">
		<div style="margin-top:10px;margin-left:40px;">
			您好!${user.name}
		</div>
		<div style="margin-left:20px;">
			<a href="#" onclick="return outlogin()">退出登录</a>
		</div>
		<div style="margin-left:700px;">
			<a href="${pageContext.request.contextPath}">商城首页 <span class="fa fa-home" style="color:#FF7F00">
			</span>
			</a>
		</div>
		<div style="margin-left:50px;">
			<a id="carta" href="${pageContext.request.contextPath}/CartController/listCartByUser.action">购物车 
			<span class="fa fa-shopping-cart"style="color:#FF7F00"></span>
			</a>
		</div>
		<div style="margin-left:50px;">
			<a  id="carta" href="${pageContext.request.contextPath}/user/center.action">个人中心 <span class="fa fa-user-circle-o"
				style="color:#FF7F00"></span>
			</a>
		</div>
	</div>
	</c:if>
	<div id="toplogo" style="border-bottom:2px solid #FF3030;height:102px;">
		<div style="margin-left: 200px;">
			<a href="${pageContext.request.contextPath}">
				<img src="${pageContext.request.contextPath}/img/juninglogo.jpg"
				width="100px" height="100px" />
			</a>
		</div>
		<div style="background:#FF3030 ;margin:36px 0 0 400px;height:30px">
			<form method="post" action="${pageContext.request.contextPath}/commodity/search.action">
				<input name="keyword" type="text"
					style="border:1px solid #FF3030;height:30px;width: 300px;color:16px">
				<input type="hidden" value="sold desc,price asc" name="sort" />
				<input type="submit" value="搜索商品"
					style="border:none;background: none;color:#fff">
			</form>
		</div>
	</div>
	<div>
		<div style="margin: 20px 0 0 75px">
			<span style="color: #636363">根据关键字"</span>
			<span style="color:#EE2C2C">${keyword}</span>
			<span style="color: #636363">"为您搜索到以下商品。</span>
		</div>
		<div style="width: 1200px;min-height: 700px;border:1px solid #969696;margin:10px auto;">
			<div style="background:#EBEBEB;width:100%;height:40px;border-bottom:1px solid #969696" id="orderby">
				<div class="orderbydiv">
			<a class="acolor" href="${pageContext.request.contextPath}/commodity/search.action?keyword=${keyword}&sort=sold desc,price asc">
					综合</a>
				</div>
				<div class="orderbydiv" style="position: relative;" id="pricehover" >
					<span>
					价格
					</span>
					<div id="pricediv" style="position: absolute;left: 0;top:0;z-index: 99;display: none">
						<a href="${pageContext.request.contextPath}/commodity/search.action?keyword=${keyword}&sort=price asc" class="orderbyA">
						价格由低到高</a>
						<a href="${pageContext.request.contextPath}/commodity/search.action?keyword=${keyword}&sort=price desc" class="orderbyA" >
						价格由高到低</a>
					</div>
				</div>
				<div class="orderbydiv">
					<a class="acolor" href="${pageContext.request.contextPath}/commodity/search.action?keyword=${keyword}&sort=sold desc">
					销量
					</a>
				</div>
				<div style="width:200px;background: #EBEBEB;height: 100%;float: left;text-align: center;padding-top:10px;">
					<form action="${pageContext.request.contextPath}/commodity/search.action" method="get" >
						<input  name="snum" placeholder="¥" type="text" style="width:40px;border: 1px solid #969696 ">
						<span>- -</span>
						<input type="hidden" value="sold desc,price asc" name="sort" />
						<input type="hidden" value="${keyword}" name="keyword" />
						<input name="ednum" placeholder="¥" type="text" style="width:40px;border: 1px solid #969696 ">
						<input type="submit" value="确定">
					</form>
				</div>
			</div>
			<div style="width: 90%;min-height: 365px;" >
			<c:if test="${commlist!=null}">
			<input type="hidden" id="whethernull" value="1">
				<c:forEach items="${commlist}" var="comm">
					<div  class="mallwindow">
						<a href="${pageContext.request.contextPath}/commodity/getComm.action?id=${comm.id}" target="_blank">
							<img src="${pageContext.request.contextPath}/file/img/${comm.titleimg}" width="221px" height="222px">
							<span class=" fa fa-yen fa-2x" style="color:#FF7F00;margin-top:5px"></span>
							<span  style="color:#FF7F00;font-size: 22px ">${comm.price }元</span>
							<br><span style="color: #999">已售出:${comm.sold}件</span><br>
							<span style="margin-left: 10px;font-size: 15px;font-weight: 600;color: #000">
							${comm.title}
							</span>
						</a>
					</div>	
				</c:forEach>
			</c:if>
			<div  style="display:none" id="rinima" >
			<h4 style='margin:100px 0 0 500px'>没有更多的商品了!</h4>
			</div>
		</div>
		<div style="position: fixed;top:95%;left:560px">
         	<a id="up" onclick="return page(this,1);" href="${pageContext.request.contextPath}/commodity/search.action?keyword=${keyword}&sort=${sort }&page=${page-1}&snum=${snum}&ednum=${ednum}" id="pagea" >
         	上一页</a>
         	<span style="margin-left:30px ">当前第</span>
         	<span style="color:#FF6347" id="pageNum">${page+1}</span>页
         	<a id="bottom" onclick="return page(this,2);" href="${pageContext.request.contextPath}/commodity/search.action?keyword=${keyword}&sort=${sort }&page=${page+1}&snum=${snum}&ednum=${ednum}" style="margin-left:30px " id="pagea2">
         	下一页</a>
         		</div>
		</div>
	</div>
	<div style="width:1100%;height:150px;">
			<div style="margin:15px 0 0 540px;color:#595959;font-size:13px;font-weight:600;
			letter-spacing:3px">
			本站由DGW制作,版权归俊宁电器所属.
			</div>
			<div style="margin:15px 0 0 595px;color:#595959;font-size:13px;font-weight:600;
			letter-spacing:3px">
				蜀ICP备20170105号
			</div>
			<div style="margin:15px 0 0 576px;color:#595959;font-size:13px;font-weight:600;
			letter-spacing:3px">
			2017-7-1  ——  2017-9-21
			</div>
	</div>
	<c:if test="${commlist==null }">
		<input type="hidden" id="whethernull">
	</c:if>
		<input type="hidden" id="path" value="${pageContext.request.contextPath}/">
 </body>
   <script type="text/javascript">
$(document).ready(function(e){
	divoff();
	$("#pricehover").hover(function(){
			$("#pricediv").css("display","block");
	},function(){
			$("#pricediv").css("display","none");
	});

});
function divoff(){
	var wns=$("#whethernull").val();
	var notdiv=$("#rinima");
	if(wns==null||wns==""){
		if($("#pageNum").html()!=1){
		notdiv.append("<input type='hidden' id='notmore' value='1'>");
		notdiv.css("display","block");
		}else{
		notdiv.html(
		"<h4 style='margin:100px 0 0 420px'>抱歉没有找到您要的商品!"
			+"您可以看看<a href='/mall' style='color:#EE7942'>其他的。</a></h4>"+
			"<input type='hidden' id='notmore' value='1'>"
		);
		notdiv.css("display","block");
		}
	}
	return false;
}
function page(data,num){
	var page=$("#pageNum").html();
	if(num==1){
	if(page==1){
	return false;
	}
	}else{
	if($("#notmore").val()!=null&&$("#notmore").val()!=''){
	return false;
	}else{
	}
	}
	return true;
}
/* 异步退出登录 */
function outlogin(){
	var path=$("#path").val();
	$.get(path+"user/outLogin.action",{},function(){
		location.reload();
	})
	return false;
}
</script>
	<style type="text/css">
.acolor{
color:#000;
}
.mallwindow{
float: left;width: 225px;height: 340px;margin-left: 20px;margin-top: 20px
   }
.mallwindow:hover{
border: 1px solid #EE7942;
   }
.orderbyA{
	display:block;height:40px;background: #EBEBEB;text-align: center;padding-top:10px;
	font-size: 12px;border-bottom:1px solid #969696;color:#262626;width:100px
}
a:hover{
text-decoration:none; 
}
.orderbydiv{
	width: 100px;background: #EBEBEB;height: 100%;float: left;text-align: center;padding-top:10px;
	font-size: 12px;

}
.orderbydiv:hover{
	cursor: pointer;border-left:1px solid #969696;border-right: 1px solid #969696;

}
#title {
	height: 550px;
	width: 90%;
	margin: 0 auto;
}

#title div {
	float: left;
}

#toplogo div {
	text-align: center;
	float: left;
}

#topdiv div {
	text-align: center;
	float: left;
	margin-top: 10px;
}
	</style>
</html>